package com.david.func_test.view

import android.app.Activity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.david.func_test.R

class SlideDeleteTestActivity:Activity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_slide_delete_test)
        val list = findViewById<RecyclerView>(R.id.list)
        list.layoutManager = LinearLayoutManager(this)
        list.adapter = AnimAdapter()
    }
}


class AnimAdapter: RecyclerView.Adapter<AnimHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AnimHolder {
//        val title = TextView(parent.context)
//        title.setPadding(0, 30, 0, 30)
//        return AnimHolder(title)
        return AnimHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_list, parent, false))
    }

    override fun onBindViewHolder(holder: AnimHolder, position: Int) {
        holder.title.text = "position is $position"
    }

    override fun getItemCount(): Int {
        return 50
    }

}

class AnimHolder(var item: View): RecyclerView.ViewHolder(item){
    val title = item.findViewById<TextView>(R.id.title)
}